From: Florian Müllner Date: Sun, 4 Oct 2015 01:06:34 +0000 (+0200) Subject: box-layout: Support replacing layout manager X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~1013^2^2~1135 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=508e751ffdb5a5356135eea85b80a5be6cc6b764;p=gnome-shell.git box-layout: Support replacing layout manager There is nothing preventing callers from replacing the internal layout manager, and as long as the replacement is a (or derives from) ClutterBoxLayout, everything should work fine except for losing a bit of automatic property mapping - and the latter is easily fixable by moving the setup out of the constructor. https://bugzilla.gnome.org/show_bug.cgi?id=708472 --- diff --git a/src/st/st-box-layout.c b/src/st/st-box-layout.c index 63e2ff717..8f01b296c 100644 --- a/src/st/st-box-layout.c +++ b/src/st/st-box-layout.c @@ -562,6 +562,24 @@ layout_notify (GObject *object, g_object_notify (self, prop_name); } +static void +on_layout_manager_notify (GObject *object, + GParamSpec *pspec, + gpointer user_data) +{ + ClutterActor *actor = CLUTTER_ACTOR (object); + ClutterLayoutManager *layout = clutter_actor_get_layout_manager (actor); + + g_warn_if_fail (CLUTTER_IS_BOX_LAYOUT (layout)); + + if (layout == NULL) + return; + + g_signal_connect_swapped (layout, "layout-changed", + G_CALLBACK (clutter_actor_queue_relayout), actor); + g_signal_connect (layout, "notify", G_CALLBACK (layout_notify), object); +} + static void st_box_layout_class_init (StBoxLayoutClass *klass) { @@ -614,14 +632,11 @@ st_box_layout_class_init (StBoxLayoutClass *klass) static void st_box_layout_init (StBoxLayout *self) { - ClutterLayoutManager *layout; - self->priv = BOX_LAYOUT_PRIVATE (self); - layout = clutter_box_layout_new (); - g_signal_connect_swapped (layout, "layout-changed", - G_CALLBACK (clutter_actor_queue_relayout), self); - g_signal_connect (layout, "notify", G_CALLBACK (layout_notify), self); - clutter_actor_set_layout_manager (CLUTTER_ACTOR (self), layout); + + g_signal_connect (self, "notify::layout-manager", + G_CALLBACK (on_layout_manager_notify), NULL); + clutter_actor_set_layout_manager (CLUTTER_ACTOR (self), clutter_box_layout_new ()); } /**